<?php
    include_once('DataProvider.php');
    
    /*******************banner 1****************/
    if($_REQUEST['ten1'] != "")
    {
        $ten = $_REQUEST['ten1'];
        $query = "UPDATE banner SET Ten = '".$ten."' WHERE MaHinh = '1'";
        DataProvider::executeQuery($query);
    }
    if($_REQUEST['thongtin1'] != "") 
    {
        $thongtin = $_REQUEST['thongtin1'];
        $query = "UPDATE banner SET ThongTin = '".$thongtin."' WHERE MaHinh = '1'";
        DataProvider::executeQuery($query);
    }
    if($_REQUEST['link1'] != "")
    {
        $link = $_REQUEST['link1'];
        $query = "UPDATE banner SET link = '".$link."' WHERE MaHinh = '1'";
        DataProvider::executeQuery($query);
    }
    if(isset($_REQUEST['submit']) && $_FILES['file1']['size'] > 0)
    {
        // Đặt biến để lấy thông tin file
			$fileName 	= $_FILES['file1']['name'];
			$tmpName 	= $_FILES['file1']['tmp_name']; 
			$fileSize 	= $_FILES['file1']['size']; 
			$fileType 	= $_FILES['file1']['type']; 
			
            //tạo biến url
            $url = $fileName;
            
            //sữa url hình
            $query = "UPDATE banner SET url = '".$url."' WHERE MaHinh = '1'";
            DataProvider::executeQuery($query);
            
            
            //Ghi file được upload vào wamp/tmp
			$fp		 = fopen($tmpName, 'r');
			$content = fread($fp, filesize($tmpName));
			$content = addslashes($content);
			fclose($fp);
			
			if(!get_magic_quotes_gpc())
			{
				$fileName = addslashes($fileName);
			}
			
			//Move file upload đã được lưu trên tmp => thư mục upload của website
			move_uploaded_file( $_FILES['file1']['tmp_name'],"../../img_admin/".$_FILES['file1']['name']);
			
    }
    
    /*******************banner 2****************/
    if($_REQUEST['ten2'] != "")
    {
        $ten = $_REQUEST['ten2'];
        $query = "UPDATE banner SET Ten = '".$ten."' WHERE MaHinh = '2'";
        DataProvider::executeQuery($query);
    }
    if($_REQUEST['thongtin2'] != "") 
    {
        $thongtin = $_REQUEST['thongtin2'];
        $query = "UPDATE banner SET ThongTin = '".$thongtin."' WHERE MaHinh = '2'";
        DataProvider::executeQuery($query);
    }
    if($_REQUEST['link2'] != "")
    {
        $link = $_REQUEST['link2'];
        $query = "UPDATE banner SET link = '".$link."' WHERE MaHinh = '2'";
        DataProvider::executeQuery($query);
    }
    if(isset($_REQUEST['submit']) && $_FILES['file2']['size'] > 0)
    {
        // Đặt biến để lấy thông tin file
			$fileName 	= $_FILES['file2']['name'];
			$tmpName 	= $_FILES['file2']['tmp_name']; 
			$fileSize 	= $_FILES['file2']['size']; 
			$fileType 	= $_FILES['file2']['type']; 
			
            //tạo biến url
            $url = $fileName;
            
            //sữa url hình
            $query = "UPDATE banner SET url = '".$url."' WHERE MaHinh = '2'";
            DataProvider::executeQuery($query);
            
            
            //Ghi file được upload vào wamp/tmp
			$fp		 = fopen($tmpName, 'r');
			$content = fread($fp, filesize($tmpName));
			$content = addslashes($content);
			fclose($fp);
			
			if(!get_magic_quotes_gpc())
			{
				$fileName = addslashes($fileName);
			}
			
			//Move file upload đã được lưu trên tmp => thư mục upload của website
			move_uploaded_file( $_FILES['file2']['tmp_name'],"../../img_admin/".$_FILES['file2']['name']);
			
    }
    
    /*******************banner 3****************/
    if($_REQUEST['ten3'] != "")
    {
        $ten = $_REQUEST['ten3'];
        $query = "UPDATE banner SET Ten = '".$ten."' WHERE MaHinh = '3'";
        DataProvider::executeQuery($query);
    }
    if($_REQUEST['thongtin3'] != "") 
    {
        $thongtin = $_REQUEST['thongtin3'];
        $query = "UPDATE banner SET ThongTin = '".$thongtin."' WHERE MaHinh = '3'";
        DataProvider::executeQuery($query);
    }
    if($_REQUEST['link3'] != "")
    {
        $link = $_REQUEST['link3'];
        $query = "UPDATE banner SET link = '".$link."' WHERE MaHinh = '3'";
        DataProvider::executeQuery($query);
    }
    if(isset($_REQUEST['submit']) && $_FILES['file3']['size'] > 0)
    {
        // Đặt biến để lấy thông tin file
			$fileName 	= $_FILES['file3']['name'];
			$tmpName 	= $_FILES['file3']['tmp_name']; 
			$fileSize 	= $_FILES['file3']['size']; 
			$fileType 	= $_FILES['file3']['type']; 
			
            //tạo biến url
            $url = $fileName;
            
            //sữa url hình
            $query = "UPDATE banner SET url = '".$url."' WHERE MaHinh = '3'";
            DataProvider::executeQuery($query);
            
            
            //Ghi file được upload vào wamp/tmp
			$fp		 = fopen($tmpName, 'r');
			$content = fread($fp, filesize($tmpName));
			$content = addslashes($content);
			fclose($fp);
			
			if(!get_magic_quotes_gpc())
			{
				$fileName = addslashes($fileName);
			}
			
			//Move file upload đã được lưu trên tmp => thư mục upload của website
			move_uploaded_file( $_FILES['file3']['tmp_name'],"../../img_admin/".$_FILES['file3']['name']);
			
    }
    
    /*******************banner 4****************/
    if($_REQUEST['ten4'] != "")
    {
        $ten = $_REQUEST['ten4'];
        $query = "UPDATE banner SET Ten = '".$ten."' WHERE MaHinh = '4'";
        DataProvider::executeQuery($query);
    }
    if($_REQUEST['thongtin4'] != "") 
    {
        $thongtin = $_REQUEST['thongtin4'];
        $query = "UPDATE banner SET ThongTin = '".$thongtin."' WHERE MaHinh = '4'";
        DataProvider::executeQuery($query);
    }
    if($_REQUEST['link4'] != "")
    {
        $link = $_REQUEST['link4'];
        $query = "UPDATE banner SET link = '".$link."' WHERE MaHinh = '4'";
        DataProvider::executeQuery($query);
    }
    if(isset($_REQUEST['submit']) && $_FILES['file4']['size'] > 0)
    {
        // Đặt biến để lấy thông tin file
			$fileName 	= $_FILES['file4']['name'];
			$tmpName 	= $_FILES['file4']['tmp_name']; 
			$fileSize 	= $_FILES['file4']['size']; 
			$fileType 	= $_FILES['file4']['type']; 
			
            //tạo biến url
            $url = $fileName;
            
            //sữa url hình
            $query = "UPDATE banner SET url = '".$url."' WHERE MaHinh = '4'";
            DataProvider::executeQuery($query);
            
            
            //Ghi file được upload vào wamp/tmp
			$fp		 = fopen($tmpName, 'r');
			$content = fread($fp, filesize($tmpName));
			$content = addslashes($content);
			fclose($fp);
			
			if(!get_magic_quotes_gpc())
			{
				$fileName = addslashes($fileName);
			}
			
			//Move file upload đã được lưu trên tmp => thư mục upload của website
			move_uploaded_file( $_FILES['file4']['tmp_name'],"../../img_admin/".$_FILES['file4']['name']);
			
    }
    
    /*******************banner 5****************/
    if($_REQUEST['ten5'] != "")
    {
        $ten = $_REQUEST['ten5'];
        $query = "UPDATE banner SET Ten = '".$ten."' WHERE MaHinh = '5'";
        DataProvider::executeQuery($query);
    }
    if($_REQUEST['thongtin5'] != "") 
    {
        $thongtin = $_REQUEST['thongtin5'];
        $query = "UPDATE banner SET ThongTin = '".$thongtin."' WHERE MaHinh = '5'";
        DataProvider::executeQuery($query);
    }
    if($_REQUEST['link5'] != "")
    {
        $link = $_REQUEST['link5'];
        $query = "UPDATE banner SET link = '".$link."' WHERE MaHinh = '5'";
        DataProvider::executeQuery($query);
    }
    if(isset($_REQUEST['submit']) && $_FILES['file4']['size'] > 0)
    {
        // Đặt biến để lấy thông tin file
			$fileName 	= $_FILES['file5']['name'];
			$tmpName 	= $_FILES['file5']['tmp_name']; 
			$fileSize 	= $_FILES['file5']['size']; 
			$fileType 	= $_FILES['file5']['type']; 
			
            //tạo biến url
            $url = $fileName;
            
            //sữa url hình
            $query = "UPDATE banner SET url = '".$url."' WHERE MaHinh = '5'";
            DataProvider::executeQuery($query);
            
            
            //Ghi file được upload vào wamp/tmp
			$fp		 = fopen($tmpName, 'r');
			$content = fread($fp, filesize($tmpName));
			$content = addslashes($content);
			fclose($fp);
			
			if(!get_magic_quotes_gpc())
			{
				$fileName = addslashes($fileName);
			}
			
			//Move file upload đã được lưu trên tmp => thư mục upload của website
			move_uploaded_file( $_FILES['file5']['tmp_name'],"../../img_admin/".$_FILES['file5']['name']);
			
    }
    
    /*******************banner 6****************/
    if($_REQUEST['ten6'] != "")
    {
        $ten = $_REQUEST['ten6'];
        $query = "UPDATE banner SET Ten = '".$ten."' WHERE MaHinh = '6'";
        DataProvider::executeQuery($query);
    }
    if($_REQUEST['thongtin6'] != "") 
    {
        $thongtin = $_REQUEST['thongtin6'];
        $query = "UPDATE banner SET ThongTin = '".$thongtin."' WHERE MaHinh = '6'";
        DataProvider::executeQuery($query);
    }
    if($_REQUEST['link6'] != "")
    {
        $link = $_REQUEST['link6'];
        $query = "UPDATE banner SET link = '".$link."' WHERE MaHinh = '6'";
        DataProvider::executeQuery($query);
    }
    if(isset($_REQUEST['submit']) && $_FILES['file6']['size'] > 0)
    {
        // Đặt biến để lấy thông tin file
			$fileName 	= $_FILES['file6']['name'];
			$tmpName 	= $_FILES['file6']['tmp_name']; 
			$fileSize 	= $_FILES['file6']['size']; 
			$fileType 	= $_FILES['file6']['type']; 
			
            //tạo biến url
            $url = $fileName;
            
            //sữa url hình
            $query = "UPDATE banner SET url = '".$url."' WHERE MaHinh = '6'";
            DataProvider::executeQuery($query);
            
            
            //Ghi file được upload vào wamp/tmp
			$fp		 = fopen($tmpName, 'r');
			$content = fread($fp, filesize($tmpName));
			$content = addslashes($content);
			fclose($fp);
			
			if(!get_magic_quotes_gpc())
			{
				$fileName = addslashes($fileName);
			}
			
			//Move file upload đã được lưu trên tmp => thư mục upload của website
			move_uploaded_file( $_FILES['file6']['tmp_name'],"../../img_admin/".$_FILES['file6']['name']);
			
    }
    
    /*******************banner 7****************/
    if($_REQUEST['ten7'] != "")
    {
        $ten = $_REQUEST['ten7'];
        $query = "UPDATE banner SET Ten = '".$ten."' WHERE MaHinh = '7'";
        DataProvider::executeQuery($query);
    }
    if($_REQUEST['thongtin7'] != "") 
    {
        $thongtin = $_REQUEST['thongtin7'];
        $query = "UPDATE banner SET ThongTin = '".$thongtin."' WHERE MaHinh = '7'";
        DataProvider::executeQuery($query);
    }
    if($_REQUEST['link7'] != "")
    {
        $link = $_REQUEST['link7'];
        $query = "UPDATE banner SET link = '".$link."' WHERE MaHinh = '7'";
        DataProvider::executeQuery($query);
    }
    if(isset($_REQUEST['submit']) && $_FILES['file7']['size'] > 0)
    {
            // Đặt biến để lấy thông tin file
			$fileName 	= $_FILES['file7']['name'];
			$tmpName 	= $_FILES['file7']['tmp_name']; 
			$fileSize 	= $_FILES['file7']['size']; 
			$fileType 	= $_FILES['file7']['type']; 
			
            //tạo biến url
            $url = $fileName;
            
            //sữa url hình
            $query = "UPDATE banner SET url = '".$url."' WHERE MaHinh = '7'";
            DataProvider::executeQuery($query);
            
            
            //Ghi file được upload vào wamp/tmp
			$fp		 = fopen($tmpName, 'r');
			$content = fread($fp, filesize($tmpName));
			$content = addslashes($content);
			fclose($fp);
			
			if(!get_magic_quotes_gpc())
			{
				$fileName = addslashes($fileName);
			}
			
			//Move file upload đã được lưu trên tmp => thư mục upload của website
			move_uploaded_file( $_FILES['file7']['tmp_name'],"../../img_admin/".$_FILES['file7']['name']);
			
    }
    
    
    
/********************************************************************************/    
    
    
    //doi body background
    
    if(isset($_REQUEST['defaultbody']))
    {
        $query = "UPDATE giaodien SET bodybg = '1'";
        DataProvider::executeQuery($query);
    }
    else
    {
        if(isset($_REQUEST['submit']) && $_FILES['file8']['size'] > 0)
        {
            // Đặt biến để lấy thông tin file
			$fileName 	= $_FILES['file8']['name'];
			$tmpName 	= $_FILES['file8']['tmp_name']; 
			$fileSize 	= $_FILES['file8']['size']; 
			$fileType 	= $_FILES['file8']['type']; 
			
            //tạo biến url
            $url = $fileName;
            
            //sữa url hình
            $query ="UPDATE giaodien SET bodybg = '".$url."'";
            DataProvider::executeQuery($query);
            
            
            //Ghi file được upload vào wamp/tmp
			$fp		 = fopen($tmpName, 'r');
			$content = fread($fp, filesize($tmpName));
			$content = addslashes($content);
			fclose($fp);
			
			if(!get_magic_quotes_gpc())
			{
				$fileName = addslashes($fileName);
			}
			
			//Move file upload đã được lưu trên tmp => thư mục upload của website
			move_uploaded_file( $_FILES['file8']['tmp_name'],"../../img_admin/".$_FILES['file8']['name']);
			
        }
    }
    
    //doi main containt background
    
    if(isset($_REQUEST['defaultmain']))
    {
        $query = "UPDATE giaodien SET mainbg = '1'";
        DataProvider::executeQuery($query);
    }
    else
    {
        if(isset($_REQUEST['submit']) && $_FILES['file9']['size'] > 0)
        {
            // Đặt biến để lấy thông tin file
			$fileName 	= $_FILES['file9']['name'];
			$tmpName 	= $_FILES['file9']['tmp_name']; 
			$fileSize 	= $_FILES['file9']['size']; 
			$fileType 	= $_FILES['file9']['type']; 
			
            //tạo biến url
            $url = $fileName;
            
            //sữa url hình
            $query ="UPDATE giaodien SET mainbg = '".$url."'";
            DataProvider::executeQuery($query);
            
            
            //Ghi file được upload vào wamp/tmp
			$fp		 = fopen($tmpName, 'r');
			$content = fread($fp, filesize($tmpName));
			$content = addslashes($content);
			fclose($fp);
			
			if(!get_magic_quotes_gpc())
			{
				$fileName = addslashes($fileName);
			}
			
			//Move file upload đã được lưu trên tmp => thư mục upload của website
			move_uploaded_file( $_FILES['file9']['tmp_name'],"../../img_admin/".$_FILES['file9']['name']);
			
        }
    }
    
    
    // doi logo
    if(isset($_REQUEST['defaultlogo']))
    {
        $query = "UPDATE giaodien SET logo = '1'";
        DataProvider::executeQuery($query);
    }
    else
    {
        if(isset($_REQUEST['submit']) && $_FILES['file10']['size'] > 0)
        {
            // Đặt biến để lấy thông tin file
			$fileName 	= $_FILES['file10']['name'];
			$tmpName 	= $_FILES['file10']['tmp_name']; 
			$fileSize 	= $_FILES['file10']['size']; 
			$fileType 	= $_FILES['file10']['type']; 
			
            //tạo biến url
            $url = $fileName;
            
            //sữa url hình
            $query ="UPDATE giaodien SET logo = '".$url."'";
            DataProvider::executeQuery($query);
            
            
            //Ghi file được upload vào wamp/tmp
			$fp		 = fopen($tmpName, 'r');
			$content = fread($fp, filesize($tmpName));
			$content = addslashes($content);
			fclose($fp);
			
			if(!get_magic_quotes_gpc())
			{
				$fileName = addslashes($fileName);
			}
			
			//Move file upload đã được lưu trên tmp => thư mục upload của website
			move_uploaded_file( $_FILES['file10']['tmp_name'],"../../img_admin/".$_FILES['file10']['name']);
			
        }
    }
    //so dong trong 1 trang
    if($_REQUEST['sodong'] != '' && is_numeric($_REQUEST['sodong']))
    {
        $query = "UPDATE giaodien SET SoDong = '".$_REQUEST['sodong']."'";
        DataProvider::executeQuery($query);
    }
    
    
    //vi tri
    
    if($_REQUEST['layout'] == 1)
    {
        $query = "UPDATE giaodien SET vitri = '1'";
        DataProvider::executeQuery($query);
    }
    else
    {
        $query = "UPDATE giaodien SET vitri = '2'";
        DataProvider::executeQuery($query);
    }
    
    
                echo '<script type = "text/javascript">';
                echo "alert('Thay đổi Thành công !');";
				echo 'window.history.go(-1);';
				echo '</script>';  
?>